package com.yzj.micro.demo.stock.controller;

import com.yzj.demo.common.response.JsonResult;
import com.yzj.demo.common.response.StatusCode;
import com.yzj.micro.demo.stock.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/stock")
@RestController
public class StockController {
    @Autowired
    private StockService stockService;
    //订单提交
    @PostMapping("reduce")
    public JsonResult<Boolean> reduce(
            String productCode,
            Integer count){
        Boolean result= stockService.reduce(productCode,count);
        if(result){
            return JsonResult.ok(result);
        }else{
            return JsonResult.error(StatusCode.OPERATION_FAILED,result);
        }
    }
}
